<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <meta name="format-detection"content="telephone=no, email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" /><!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 设置苹果工具栏颜色 -->
    <meta name=”renderer” content="ie-comp">
    <meta name=”renderer” content=”ie-stand”>
    <meta name="renderer" content="webkit"> 
    <meta name="keywords" content="财子科技官网"/>
    <meta name="description" content="财子科技专注于为大众富裕阶层、精英个人、中产阶级家庭、合规机构等提供定制化资产配置咨询推荐服务，帮助客户实现财富的增值。" />
    <title>财子科技</title>
    <script src="../lib/js/ftSize.js"></script>
    <link rel="stylesheet" href="../lib/css/_base.css">
    <link rel="stylesheet" href="../lib/css/login.css">
</head>
<body>
    <div class="mobile-page" id="mobile-page">
        <img src="../lib/images/caizikeji/home_index_header.png" class="login_header_img"/>
        <section>
                <span class="login-icon">
                   手机号
                </span>
                <span class="login-input" id="registerUser">
                   <input type="tel" id="registerMobile" maxlength="13" onKeyPress="mobileValidation(event.keyCode||event.which)" onafterpaste="this.value=this.value.replace(/\D/g,'')" onkeyup="doSet(this)"/>
                </span>
                
            </section>
            <section id="registerVerif">
                    <span class="register-sms">
                       验证码
                    </span>
                    <span class="register-input" id="smsUser">
                        <input type="text" id="registerSms" maxlength="6">
                        <div class="T-getCode" id="btnSendCode">获取验证码</div>
                    </span>
                 
                </span>
            </section>
            <div class="register-agreed">
                    <label id="my_protocol"><input type="checkbox"><i>✓</i>我同意</label>
                    <a href="registerAgreement.html" id="register-text">《财子科技会员注册协议》</a>
            </div>
            <div class="reminder-warning-tip" id="regreminder"></div>
        <div class="wap2-loginBtn" id="nextLogin" onclick="fnLogin()" disabled="false">
            登录
        </div>
  </div>
<script src="../lib/js/jquery.min.js"></script>

<script src="../lib/js/public-header.js"></script>
<script>
    var isRegisterMsg;
$('.login-warning-tip').text(' ')
function phoneValidation(ev){//键盘事件
    if(ev == 13){
       fnLogin()
    }
}
//是否注册
function isRegistJson(mobile) {
    var json = {
        "faceCode":"user/registerCheck",
        "token":"",    
        "clientInfo":"W,100,IE8",  
        "requestTime": formatDateTime(startTime),
        "body":{
            "mobile":mobile,
            "flag":"1"
        }
       
     }
    return json;
}
/* 登录传递的数据 */
function loginJson(mobile,pwd) {
    var json = {
        "faceCode":"user/login",
        "token":"",
        "clientInfo":"W,100,IE8",
        "requestTime": formatDateTime(startTime),
        "body":{
            "mobile":mobile,
            "loginPwd":pwd,
            "loginType":'1',
            "imgCode":'',
            "isFlag":"2",
            "smsCode":""
        }
     }
    return json;
}

/* 判断是否注册 */
function isRegistered(registerMobile){
     $.ajax({  
        type: "POST",
        url: httpServer+"user/registerCheck",
        headers:{
            'Access-Control-Allow-Origin':'*'
        }, 
        async:false,
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(isRegistJson(registerMobile)),
        dataType: "json",
        success: function (isMobile) {  
        
            isRegisterMsg=isMobile 
        },
        error: function(error){  
            console.log(error,1);  
        }    
    }); 
} 
    //手机号判断
    function fnLogin() {
        let loginMobile=$('#loginMobile').val().replace(/\s/g, "");
        let loginPassword=$('#loginPassword').val().trim();
        if(loginMobile!=''){
            if(startPhone.test(loginMobile) ){
                if(loginPassword!=''){
                    if(payPwd.test(loginPassword)){
                        $('#nextLogin').attr('disabled','true');
                        $('#nextLogin').removeClass('addLogin')
                        //请求后端
                        $('.login-warning-tip').text(' ')
                        $.ajax({  
                            type: "POST",
                            url: httpServer+"user/login",
                            headers:{'Access-Control-Allow-Origin':'*'}, 
                            contentType: "application/json; charset=utf-8",
                            data: JSON.stringify(loginJson(loginMobile,loginPassword)),
                            dataType: "json",
                            success: function (loginShow) {  
                                if(loginShow.resCode!='0'){
                                    $('.login-warning-tip').text(loginShow.errorMsg);
                                   
                                }else{
                                    if(window.sessionStorage.getItem('wprouterFrom')!='/InsuranceDetails/index.html'){
                                        window.location.href="../mine/index.html"
                                    }else{
                                        window.location.href="../productList/InsuranceDetails/index.html"
                                    }
                                   
                                   // window.history.go(-1);
                                   // window.location.href="../mine/index.html"
                                    let userInfo = {
                                        avatar: loginShow.body.avatar, //头像
                                        userId: loginShow.body.userId,//用户id
                                        userPhone: loginShow.body.mobile,//手机号
                                        userName: loginShow.body.userName,//用户名
                                        certNo: loginShow.body.certNo, //身份证
                                        bankCardNo: loginShow.body.bankCardNo, //银行卡
                                        startTime: loginShow.body.requestTime,
                                        token: loginShow.body.token,
                                        riskFlag:loginShow.body.riskFlag
                                    };
                                    window.sessionStorage.setItem('wpuserToken', loginShow.body.token);
                                    window.sessionStorage.setItem('wpavailableAmount', loginShow.body.availableAmount);//可用余额
                                    window.sessionStorage.setItem('wpcertFlag', loginShow.body.certFlag) //认证标志 1认证2未认证
                                    window.sessionStorage.setItem("wpuserInfo", JSON.stringify(userInfo)); //是否登录
                                    window.sessionStorage.setItem('wpriskFlag', loginShow.body.riskFlag)// 1评测，2:未评测
                                }
                        },
                        error: function(error){  
                            console.log(error);  
                            }    
                        }); 
                    }else{
                        $('.login-warning-tip').text('请输入6~16位字母数字组合')
                    }
                }else{
                    $('#nextLogin').addClass('addLogin')  
                    $('.login-warning-tip').text('密码不能为空')
                }
            }else{
                $('.login-warning-tip').text('请输入正确手机号')
            } 
        }else{
            $('.login-warning-tip').text('手机号不能为空')
            if($('#nextLogin').attr('class')!='addLogin'){
                $('#nextLogin').removeClass('addLogin')
            }
            blurInput()
        } 
    }
    /* 手机号失去焦点 */
    $('#loginMobile').blur(function(){
        fnLogin()
        blurInput()
    })  
    /* 登录密码失去焦点 */
    $('#loginPassword').blur(function(){
        fnLogin()
        blurInput()
    })
    /* 手机号获取焦点 */
    $('#loginMobile').focus(function(){
        $('.login-warning-tip').text(' ')
        if($('#mobileUser').attr('class')!='login-inputActive'){
            $('#mobileUser').addClass('login-inputActive')
        }
    });
    /* 登录密码获取焦点 */
    $('#loginPassword').focus(function(){
        
        let loginMobile=$('#loginMobile').val().replace(/\s/g, "");
        isRegistered(loginMobile)
        if(isRegisterMsg.resCode!='0'){
            $('.login-warning-tip').text(isRegisterMsg.errorMsg);
          
        }else{
            $('.login-warning-tip').text(' ')
            $('#nextLogin').addClass('addLogin')
            if($('#passwordUser').attr('class')!='login-inputActive'){
                $('#passwordUser').addClass('login-inputActive')
            }
        }
    });
  
/* 登录密码失去焦点 */ 
    function blurInput(){
        if($('#mobileUser').attr('class').indexOf('login-inputActive')!=-1 ){
            $('#mobileUser').removeClass('login-inputActive')
        }else if($('#passwordUser').attr('class').indexOf('login-inputActive')!=-1){
                $('#passwordUser').removeClass('login-inputActive')
        }
    }
function focusInput(){
    if($('#mobileUser').attr('class')!='login-inputActive'){
        $('#mobileUser').addClass('login-inputActive')
    }else if($('#passwordUser').attr('class')!='login-inputActive'){
        $('#passwordUser').addClass('login-inputActive')
    }
  
}



</script>
</body>
</html>